//-----------------------------------------------------------------------------
// mapViewer.h
// super class : Viewer3D
// sous class :
//
// class displaying the map of the circuit
//-----------------------------------------------------------------------------

#ifndef MAPVIEWER
#define MAPVIEWER 1

#include "AReVi/message.h"
#include "AReVi/activity.h"

#include "AReVi/Lib3D/texture.h"
#include "AReVi/Lib3D/viewer3D.h"
#include "AReVi/Lib3D/osdText.h"
#include "AReVi/Lib3D/osdSprite.h"

using namespace AReVi;

class AReViRoadViewer;

//-----------------------------------------------------------------------------
// Class MapMarker
//-----------------------------------------------------------------------------

class MapMarker : public Base3D
{
public: 
 
  AR_UNSTUBBED AR_CLASS(MapMarker)

//-------- Construction / Destruction -----------------------------------------  
    
  AR_CONSTRUCTOR_2(MapMarker, StlString, name, StlString, type)
  
//-------- User defined interactions ------------------------------------------

  StlString
  getName(void);

  StlString
  getUserType(void);
    
  int 
  getID(void);
  
protected:

  bool
  _activate(ArRef<Activity> act , double dt);
  
  void
  _onMotionCB(const Base3D::MotionEvent& evt);

  static int _nbInstance;
  
  ArRef<MessageService> _messageService;
  ArRef<Activity> _act;
  bool _motionFlag;
  StlString _name;
  StlString _userType;
  int _id;
};

//-----------------------------------------------------------------------------
// Class MapMarkerMessage
//-----------------------------------------------------------------------------

class MapMarkerMessage : public Message
{
public: 
 
  AR_UNSTUBBED AR_CLASS(MapMarkerMessage)

//-------- Construction / Destruction -----------------------------------------  
    
  AR_CONSTRUCTOR(MapMarkerMessage)
  
//-------- User defined interactions ------------------------------------------

  inline
  const Util3D::Base &
  getBase(void) const;

  inline
  void
  setBase(const Util3D::Base &base);

  inline
  StlString
  getAction(void) const;

  inline
  void
  setAction(const StlString & action);
  
  inline
  StlString
  getUserName(void) const;

  inline
  void
  setUserName(const StlString & userName);  
  
  inline
  StlString
  getUserType(void) const;

  inline
  void
  setUserType(const StlString & userType);    
  
  inline
  int
  getID(void) const;

  inline
  void
  setID(const int & id);  
  
protected:

  Util3D::Base _base;
  StlString _action;
  StlString _userName;
  StlString _userType;
  int _id;  
};

// Inline Implementation

const Util3D::Base &
MapMarkerMessage::getBase(void) const {
  return _base;
}

void
MapMarkerMessage::setBase(const Util3D::Base &base) {
  _base = base;
}


StlString
MapMarkerMessage::getAction(void) const {
  return _action;
}

void
MapMarkerMessage::setAction(const StlString & action){
  _action = action;
}

StlString
MapMarkerMessage::getUserName(void) const{
  return _userName;
}

void
MapMarkerMessage::setUserName(const StlString & userName){
  _userName = userName;
}

StlString
MapMarkerMessage::getUserType(void) const{
  return _userType; 
}

void
MapMarkerMessage::setUserType(const StlString & userType){
  _userType = userType;
}

int
MapMarkerMessage::getID(void) const{
  return _id;
}

void
MapMarkerMessage::setID(const int & id){
  _id = id;
}

//-----------------------------------------------------------------------------
// Class MapViewer
//-----------------------------------------------------------------------------

class MapViewer : public ArObject
{
//-------- Type information ---------------------------------------------------

public:
  AR_UNSTUBBED AR_CLASS(MapViewer)

//-------- Construction / Destruction -----------------------------------------  
    
  AR_CONSTRUCTOR_1(MapViewer, ArRef<Scene3D>, scene)
  
//-------- User defined interactions ------------------------------------------

  void
  show(ArRef<Viewer3D> viewer);

  void
  hide(ArRef<Viewer3D> viewer);  
  
  void
  update(void);

  bool
  isShown(ArRef<Viewer3D> viewer);
    
protected:

//   bool
//   _activate(ArRef<Activity> act , double dt);
  void
  _onMessageCB(const MessageEvent & evt);


  ArRef<MessageService> _messageService;
  ArRef<Activity> _act; 
  StlVector<ArRef<AReViRoadViewer> > _viewers;
  ArRef<OSDSprite> _road;
  StlMap<int,ArRef<OSDSprite> > _items;
  StlMap<int,ArRef<OSDText> > _names;  
  unsigned int _sizeX,_sizeY;
  double _xmin, _ymin, _xmax, _ymax;
  
};

#endif //MapViewer

//-----------------------------------------------------------------------------

